package com.running.base.run.config;

import org.eclipse.jetty.util.thread.ExecutorThreadPool;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 * Created by Daniel on 29/09/2016.
 */

@Configuration
public class JettyConfig {

    @Value("${server.port}")
    private int port;

    @Bean
    public EmbeddedServletContainerFactory servletContainer() {
        JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory();
        factory.setPort(port);
        factory.setSessionTimeout(30, TimeUnit.MINUTES);
        
        ExecutorThreadPool threadPool = new ExecutorThreadPool(200);
        factory.setThreadPool(threadPool);
        return factory;
    }

}
